package model;
import java.util.ArrayList;

/**
* Title: Bucket.java<br>
* Description: class for saving bucket data<br>
* Created: 05.01.2013<br>
* Copyright: Copyright (c) 2012<br>
* Company: Luxoft Corporation
* @author Sveta
* @version $Rev$: , $Date$: , $Author$:
*/
public class Bucket  {
	private int id;
	private String name;
	private ArrayList<Product> products = new ArrayList<Product>();
	
	public ArrayList<Product> getProducts() {
		return products;
	}

	public void setProducts(ArrayList<Product> products) {
		this.products = products;
	}

	@Override
	public String toString() {
		return "Bucket [id=" + id + ", name=" + name + ", products=" + products
				+ "]";
	}

	

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void add(Product pr) {
		products.add(pr);
	}
	
	/**
	* Title: Bucket.java.printBucket<br>
	* Description: method to print Bucket<br>
	* Created: 05.01.2013<br>
	* Copyright: Copyright (c) 2012<br>
	* Company: Luxoft Corporation
	* 
	*/
	public void printBucket() {
		for (Product prod : products) {
			System.out.println(prod);
		}
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + id;
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result
				+ ((products == null) ? 0 : products.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Bucket other = (Bucket) obj;
		if (id != other.id)
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		if (products == null) {
			if (other.products != null)
				return false;
		} else if (!products.equals(other.products))
			return false;
		return true;
	}

	

	

}
